package com.fulihui.weixinsdk.request.tag;

import com.alibaba.fastjson.JSON;
import com.fulihui.weixinsdk.http.HttpMethodEnum;
import com.fulihui.weixinsdk.request.WeixinRequest;
import com.fulihui.weixinsdk.result.tag.TagCreateResult;
import com.google.gson.Gson;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;
import java.util.TreeMap;

/**
 * 公众号创建标签
 * Created by wang_wx on 2017/09/13 0030.
 */
@Data
public class TagCreateRequest extends WeixinRequest<TagCreateResult> {
    private transient String access_token;
    private String name;//标签名

    @Override
    public Map<String, String> urlParam() {
        Map<String, String> param = new TreeMap<>();
        if (StringUtils.isNotBlank(access_token)) {
            param.put("access_token", access_token);
        }
        return param;
    }

    @Override
    protected void childParam() {

    }

    @Override
    public String service() {
        return "https://api.weixin.qq.com/cgi-bin/tags/create";
    }

    @Override
    public String urlEndStr() {
        return null;
    }

    @Override
    public TagCreateResult parseResult(String respStr) {
        return new Gson().fromJson(respStr, TagCreateResult.class);
    }

    @Override
    public HttpMethodEnum httpMethod() {
        return HttpMethodEnum.POST;
    }

    @Override
    public String requestData() {
        return JSON.toJSONString(this);
    }
}
